<?php

// Call The Correct Brand Icon Image For The Brochure Cover
if (get_post_meta($post->ID, 'ProductBrand', true) == GridMaxx) {
	$brochureBrandImage = GridMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == ThermoPower) {
	$brochureBrandImage = ThermoPowerIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == TitanPower) {
	$brochureBrandImage = TitanPowerIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == ConnectMaxx) {
	$brochureBrandImage = ConnectMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == StorMaxx) {
	$brochureBrandImage = StorMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == FlowMaxx) {
	$brochureBrandImage = FlowMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == UniMaxx) {
	$brochureBrandImage = UniMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == SmartMaxx) {
	$brochureBrandImage = IngelliMaxxIcon;
} elseif (get_post_meta($post->ID, 'ProductBrand', true) == HelioMaxx) {
	$brochureBrandImage = HelioPrepackKits;
}

// Set The Basic Variables For Building The Brochure
$brochureTitle = get_post_meta($post->ID, 'ProductBrochureTitle', true);
$brochureFrontImage = get_post_meta($post->ID, 'ProductBrochureFrontImage', true);
$brochureFrontFeatureOneTitle = get_post_meta($post->ID, 'ProductBrochureFrontFeatureOneTitle', true);
$brochureFrontFeatureOneContent = get_post_meta($post->ID, 'ProductBrochureFrontFeatureOneContent', true);
$brochureFrontFeatureTwoTitle = get_post_meta($post->ID, 'ProductBrochureFrontFeatureTwoTitle', true);
$brochureFrontFeatureTwoContent = get_post_meta($post->ID, 'ProductBrochureFrontFeatureTwoContent', true);
$brochureFrontFeatureThreeTitle = get_post_meta($post->ID, 'ProductBrochureFrontFeatureThreeTitle', true);
$brochureFrontFeatureThreeContent = get_post_meta($post->ID, 'ProductBrochureFrontFeatureThreeContent', true);
$brochureFrontFeatureFourTitle = get_post_meta($post->ID, 'ProductBrochureFrontFeatureFourTitle', true);
$brochureFrontFeatureFourContent = get_post_meta($post->ID, 'ProductBrochureFrontFeatureFourContent', true);
$brochureFrontFeatureFiveTitle = get_post_meta($post->ID, 'ProductBrochureFrontFeatureFiveTitle', true);
$brochureFrontFeatureFiveContent = get_post_meta($post->ID, 'ProductBrochureFrontFeatureFiveContent', true);
$brochureBackTopTitle = get_post_meta($post->ID, 'ProductBrochureBackTopTitle', true);
$brochureBackTopContent = get_post_meta($post->ID, 'ProductBrochureBackTopContent', true);
$brochureBackTopImage = get_post_meta($post->ID, 'ProductBrochureBackTopImage', true);
$brochureBackTableOneTitle = get_post_meta($post->ID, 'ProductBrochureBackTableOneTitle', true);
$brochureBackTableOneContent = get_post_meta($post->ID, 'ProductBrochureBackTableOneContent', true);
$brochureBackImageTwo = get_post_meta($post->ID, 'ProductBrochureBackImageTwo', true);
$brochureBackImageThree = get_post_meta($post->ID, 'ProductBrochureBackImageThree', true);


$pdf_html_header 			= false; //If this is ture you can write instead of the array a html string on the var $pdf_header
$pdf_html_footer 			= false; //If this is ture you can write instead of the array a html string on the var $pdf_footer
		

	$pdf_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
		<html xml:lang="en">
		
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<title>' . get_bloginfo() . '</title>
			
		</head>
		
		<body xml:lang="en">
		
			<bookmark content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" /><tocentry content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" />
			
			<style>
				
				@page { size: 8.5in 11in;
					background-image: url("images/printDataSheetBodyBG.jpg");
				}
				
				body { font-family:arial;font-size:12px; }
				table { font-family:arial;font-size:12px; }
				h1 { font-size:20px;font-weight:bold;color:#ffffff;line-height:20px;margin:0px;background:none; }
				h2 { font-size:30px;font-weight:bold;color:#ffffff;line-height:30px;margin:0px;background:none; }
				h3 { font-size:20px;font-weight:bold;color:#002d55;line-height:20px;margin:0px;margin-bottom:5px;background:none; }
				h4 { font-size:14px;font-weight:bold;color:#002d55;line-height:15px;margin:0px;margin-bottom:10px; }
					h4.brochureFrontFeatureContent { font-weight:normal;padding-bottom:10px; }
					
				.datatable { width:48%;margin:0px;height:26px;line-height:26px;border-bottom:#000000 1px solid; }
					.datatableleft { float:left; }
					.datatableright { float:right;text-align:right; }
				
			</style>
		';
			
			while (have_posts()) : the_post();

				$pdf_output .= '
					<table width="700" cellpadding="0" cellspacing="0" style="font-family:arial;" border="0">
						<tr>
							<td height="420">
								<img src="images/brochureFrontLogo.jpg" width="700" />
							</td>
						</tr>
						<tr>
							<td>
								<table width="700px" cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td width="100" height="100" align="center" bgcolor="#e77d1d">
											<img src="http://www.sunmaxxsolar.com/images/'.$brochureBrandImage.'.png" height="100" />
										</td>
										<td width="600" height="50" bgcolor="#e77d1d" align="right" style="padding-right:25px;padding-top:25px;padding-bottom:25px;">
											<h1>SunMaxx</h1>
											<h2>' . $brochureTitle . '</h2>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td height="403">
								<table width="700" height="400" cellpadding="0" cellspacing="0" border="0" >
									<tr>
										<td width="325" height="400" bgcolor="#d0d7de" valign="top" style="padding:25px;">
											<h3 class="brochureFrontFeatureTitle">'. $brochureFrontFeatureOneTitle .'</h3>
											<h4 class="brochureFrontFeatureContent">'. $brochureFrontFeatureOneContent .'</h4>
                        					<h4>&nbsp;</h4>
											<h3 class="brochureFrontFeatureTitle">'. $brochureFrontFeatureTwoTitle .'</h3>
											<h4 class="brochureFrontFeatureContent">'. $brochureFrontFeatureTwoContent .'</h4>
                        					<h4>&nbsp;</h4>
											<h3 class="brochureFrontFeatureTitle">'. $brochureFrontFeatureThreeTitle .'</h3>
											<h4 class="brochureFrontFeatureContent">'. $brochureFrontFeatureThreeContent .'</h4>
                        					<h4>&nbsp;</h4>
											<h3 class="brochureFrontFeatureTitle">'. $brochureFrontFeatureFourTitle .'</h3>
											<h4 class="brochureFrontFeatureContent">'. $brochureFrontFeatureFourContent .'</h4>
											<h4>&nbsp;</h4>
											<h3 class="brochureFrontFeatureTitle">'. $brochureFrontFeatureFiveTitle .'</h3>
											<h4 class="brochureFrontFeatureContent">'. $brochureFrontFeatureFiveContent .'</h4>
										</td>
										<td width="275" height="400" valign="top" style="padding:25px;">
											<img src="'. $brochureFrontImage .'" width="275" />
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td height="40" bgcolor="#002d55">&nbsp;</td>
						</tr>
					</table>
				';
				
				if (get_post_meta($post->ID, 'ProductBrochureTemplate', true) == '1 Column') {
					include ('printBrochure1Column.php');
				} elseif (get_post_meta($post->ID, 'ProductBrochureTemplate', true) == '2 Column') {
					include ('printBrochure2Column.php');
				}
			
				
			endwhile ;
	
	$pdf_output .= '
		</body>
		</html>';
?>
